package com.alageek.study;

import java.util.HashMap;
import java.util.Map;

public class BigCharFactory {

    private final Map<String, BigChar> pool = new HashMap<>();
    private static final BigCharFactory singleton = new BigCharFactory();

    private BigCharFactory() {

    }

    public static BigCharFactory getInstance() {
        return singleton;
    }

    public synchronized BigChar getBigChar(char charname){
        BigChar bc = pool.get("" + charname);
        if(bc==null){
            bc = new BigChar(charname);
            pool.put(""+charname, bc);
        }
        return bc;
    }

}
